#ifndef EPAPER_HPP
#define EPAPER_HPP

#include "MonoChromeScreen.hpp"
#include "IODevice.hpp"
#include "Pin.hpp"

class Color{
public:
    unsigned data;
};

class EPaper : public MonoChromeScreen{
public:
    EPaper(IODevice *bus,Pin *nss,Pin *dc,Pin *rst,Pin *busy,int width,int height);
    ~EPaper();
    virtual void setPixel(int x,int y,Color color);
    virtual Color getPixel(int x,int y);
    virtual void setColumn(int column,int row,unsigned char data);
    virtual unsigned char getColumn(int column,int row);
    void init();
    void refresh();
    void sleep();
    void clear();
private:
    void waitBusy();
    void reset();
    void sendCommand(unsigned char command);
    void sendData(unsigned char data);
private:
    unsigned char *framebuffer; /* 帧缓冲 */
    int width;
    int height;
    IODevice *bus;
    Pin *nss;
    Pin *dc;
    Pin *rst;
    Pin *busy;
};

#endif